package com.friendfeed.api;

import org.json.JSONException;
import org.json.JSONObject;

public class MediaThumbnail {
    private String url;
    private int width;
    private int height;

    public MediaThumbnail(String url, int width, int height) {
        this.url = url;
        this.width = width;
        this.height = height;
    }

    public MediaThumbnail(JSONObject jsonObject) throws JSONException {
        url = jsonObject.getString("url");

        if (jsonObject.has("width") && !jsonObject.isNull("width")) {
            width = jsonObject.getInt("width");
        }

        if (jsonObject.has("height") && !jsonObject.isNull("height")) {
            height = jsonObject.getInt("height");
        }
    }

    public String getUrl() {
        return url;
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    public String toString() {
        return "MediaThumbnail{" +
                "height=" + height +
                ", width=" + width +
                ", url='" + url + '\'' +
                '}';
    }
}
